/*
 * @Author: codeD
 * @Date: 2022-02-17 20:12:05
 * @LastEditors: codeD
 * @LastEditTime: 2022-02-19 14:55:27
 * @Description: file content
 * @FilePath: \wpt\src\App.effect.tsx
 */
import { MENE_LIST } from "config";
import { useState } from "react";
import {NavigatorConfigItem} from './config'
import {UseNavigator} from './App.type'
export const useNavigator:UseNavigator = () => {
    const initCurrent = MENE_LIST.findIndex(item => item.path === location.pathname)
    const [current, setCurrent] = useState(initCurrent);
    const isShow = (initCurrent !== -1);
    const handleNavigatorRouter = (item:NavigatorConfigItem, index:number) => {
      window.history.pushState(null, '', item.path);
    
      setCurrent(index);
      window.location.reload()
    };
    return {
      current,
      isShow,
      handleNavigatorRouter,
    };
  };
  